Skip to content

fix: apply span changes on history recorded before 0.20 - #334

Merged
geekgonecrazy merged 1 commit into
devfrom
fix/span-preflight-legacy-hash
Nov 13, 2026
Merged

geekgonecrazy merged 1 commit into
devfrom
fix/span-preflight-legacy-hash

Conversation

@vinceblock99

Copy link
Copy Markdown
Contributor

Problem

If a repo's history has changes recorded before 0.20, a span change that depends on them cannot be applied anywhere else. pull, a fresh clone and insert from another view all fail with:

Apply error: change hash mismatch

The repo is not damaged, but nobody else can receive the span change.

Spans are still off in release builds, so this does not hit users today. It blocks migrating existing repos to spans.

Cause

Before applying a span change, preflight_span_references checks every change it depends on against its hash. It re-encoded each change with the current writer and hashed the result. A change recorded before 0.20 keeps the hash of its original encoding, so the two never match.

Fix

The check now verifies the stored bytes against the requested hash, instead of a re-encoding. Old changes stay as they are; no upgrade of old changes is needed. A dependency stored under the wrong hash is still refused.

Tests

  • New legacy_history_span_insert_tests, using a real change recorded by the released 0.19.1 as a fixture. Covers pull, clone and insert from another view (these three fail with the error above before the fix), plus a test that a dependency stored under the wrong hash is still refused.
  • Against a real atomic-storage server, with history recorded by 0.19.1 and a span change pushed by 0.22.0: released 0.22.0 fails on both pull and fresh clone; with this fix both succeed, files match the pusher's and doctor check is consistent.
  • cargo test --workspace --features atomic-cli/adoption-test-injection: 11,413 passed, 0 failed.
  • cargo fmt --all -- --check and cargo clippy --workspace -- -D warnings clean.

Inserting a span change failed with "Apply error: change hash mismatch"
whenever it depended on a change recorded before 0.20.

Before applying a span change, preflight_span_references checks every
change it depends on against its hash. It did that by re-encoding the
change with the current writer and hashing the result. A change recorded
before 0.20 keeps the hash of its original encoding, so the re-encoded
hash never matches.

The check now verifies the stored bytes against the requested hash. A
dependency stored under the wrong hash is still refused.
@geekgonecrazy
geekgonecrazy merged commit 03f184e into dev Nov 13, 2026
10 checks passed
@geekgonecrazy
geekgonecrazy deleted the fix/span-preflight-legacy-hash branch November 13, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants